<template>
	<view>
		<view class="pt100 cen">
			<image :src="info.avatar" class="yj usjhgdhrt cz" mode=""></image>
			<view class="fz40 cf mt40">
				{{info.alias}}
			</view>
			<view class="z9 fz26 mt20">
				{{info.job_title}}
			</view>
		</view>
		<view class="mt90 pd">

			<view class="" v-if="type==0">
				<view class="z9 fz26">
					组织名称
				</view>
				<view class="mt30 cf">
					{{info.name}}
				</view>
				<view class="z9 fz26 mt80">
					电话
				</view>
				<view class="mt30 cf">
					{{info.phone}}
				</view>
			</view>

			<view class="" v-if="type==1">
				<view class="row">
					<text class="f_b jhhncert z9 fz28">姓名</text>
					<view class="col">
						<input type="text" value="" placeholder="请输入姓名" class="jhhgerttyt" v-model="form.alias"/>
					</view>
				</view>
				<view class="row mt70">
					<text class="f_b jhhncert z9 fz28">职务</text>
					<view class="col">
						<input type="text" value="" placeholder="请输入职务" class="jhhgerttyt" v-model="form.job_title"/>
					</view>
				</view>
			</view>

		</view>

	</view>
</template>
<script>
	export default {
		data() {
			return {
				type: 0,
				info:"",
				form:{
					alias:'',
					job_title:''
				},
				oid:"",
				id:""
			}
		},
		components: {},
		onLoad(options) {
			this.id=options.id
			this.oid=options.oid
			this.getfetch(options.oid,options.id)
		},
		methods: {
			setStyle(index, text) {
				let pages = getCurrentPages();
				let page = pages[pages.length - 1];
				// #ifdef APP-PLUS
				let currentWebview = page.$getAppWebview();
				let titleNView = currentWebview.getStyle().titleNView;
				// 添加文字过长截取为3个字符，请根据自己业务需求更改
				titleNView.buttons[0].text = text;
				currentWebview.setStyle({
					titleNView: titleNView
				});
				// #endif
				// #ifdef H5
				// h5 临时方案
				document.getElementsByClassName('uni-btn-icon')[1].innerText = text;
				// #endif
			},
			async getfetch(oid,id){
				var info=await this.get("/api/organization_user/organization/"+oid+"/user/"+id)				
				this.info=info.data			
				
			},
			async modify(){
				var params=""
				this.form.oid=this.oid
				this.form.id=this.id				
				var xiugai=await this.get("/api/organization_user",this.form,"PUT")
				console.log("修改信息",xiugai)
			}
		},
		onShow() {
			this.getfetch(this.oid,this.id)
		},
		onNavigationBarButtonTap() {
			let hgghsd = '编辑'
			if (this.type == 0){
				this.form.alias=this.info.alias
				this.form.job_title=this.info.job_title
				this.type =1
				hgghsd = '完成'
			}else if (this.type == 1){
				this.modify()
				this.type=0
			}
			this.setStyle(0, hgghsd);
		},
		mounted() {}
	}
</script>
<style scoped>
	.usjhgdhrt {
		width: 278upx;
		height: 278upx;
	}

	.jhhncert {
		width: 110upx;
		line-height: 106upx;
	}
</style>
